import java.util.Scanner;

public class Test11 {
    public static long combination(int n, int m) {
        if (m > n || m < 0 || n < 0) {
            return 0; 
        }
        
        long numerator = 1;
        long denominator = 1;
        
        for (int i = 1; i <= m; i++) {
            numerator *= (n - i + 1); 
            denominator *= i;
        }
        
        return numerator / denominator;
    }

    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);
        int count = reader.nextInt();
        
        for (int i = 0; i < count; i++) {
            int n = reader.nextInt();
            int m = reader.nextInt();
            System.out.println(combination(n, m));
        }
        
        reader.close();
    }
}